﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XMouse360
{
	public partial class TesterForm : Form
	{
		private delegate void ClearItemsCallback();
		private delegate void AddItemCallback(string s);

		public TesterForm()
		{
			InitializeComponent();
		}

		private void ValueBox_SelectedIndexChanged(object sender, EventArgs e)
		{

		}

		public void ClearItems()
		{
			if (this.ValueBox.InvokeRequired)
			{
				ClearItemsCallback c = new ClearItemsCallback(ClearItems);
				if(!this.IsDisposed)
					this.Invoke(c);
			}
			else
			{
				ValueBox.Items.Clear();
			}
		}

		public void AddItem(string s)
		{
			if (this.ValueBox.InvokeRequired)
			{
				AddItemCallback a = new AddItemCallback(AddItem);
				if(!this.IsDisposed)
					this.Invoke(a, new object[] { s });
			}
			else
			{
				ValueBox.Items.Add(s);
			}
		}
	}
}
